package helper.scxml.scxml2.t0.case1_cycle.zone

import helper.scxml.scxml2.EnvHelper.StateEventDataUnit.Companion.makeStateEventDataUnit
import helper.scxml.scxml2.EnvHelper.RunResult
import org.junit.Test

internal class CycleEnvHelperTest {
    @Test
    fun t1() {
        // 创建一个原始的RunResult对象
        val original = RunResult(
            arrayListOf(
                makeStateEventDataUnit(
                    "Location1",
                    "Action1",
                    linkedMapOf("key1" to "value1"),
                )
            ),
            arrayListOf("EndState1"),
            linkedMapOf("endKey1" to "endValue1"),
        )

        // 克隆这个RunResult对象
        val clone = original.deepClone()

        // 输出原始对象和克隆对象，以确保它们在内容上是相同的
        println("Original: $original")
        println("Clone: $clone")

        // 修改原始对象
        original.us[0].data["key1"] = "newValue1"
        original.endStateList[0] = "NewEndState1"
        original.endData["endKey1"] = "newEndValue1"

        // 输出修改后的原始对象和克隆对象，以确保克隆对象没有被改变
        println("Modified Original: $original")
        println("Unmodified Clone: $clone")

        // 验证克隆对象是否真的没有被改变
        if (clone.us[0].data["key1"] == "value1" && clone.endStateList[0] == "EndState1" && clone.endData["endKey1"] == "endValue1") {
            println("Deep clone is successful!")
        } else {
            println("Deep clone failed!")
        }
    }
}